import axios from '@/libs/api.request'
import config from '@/config'

/**
 * 按批次查询
 * */
export const getBatchList = data => {
  return axios.request({
    url: '/sysInbound/querySysInbound',
    data,
    method: 'post'
  })
}

/**
 * 批次列表=>作废
 * */
export const cancellationBatch = data => {
  return axios.request({
    url: '/sysInbound/sysObsInbound',
    data,
    method: 'post'
  })
}

/**
 * 按明细查询
 * */
export const detailsList = data => {
  return axios.request({
    url: '/sysInbound/selSysByDetails',
    data,
    method: 'post'
  })
}

/**
 * 根据租户查询厂商
 * */
export const vendorList = data => {
  return axios.request({
    url: '/sysInbound/likeTenant',
    data,
    method: 'post'
  })
}

/**
 * 明细=> 查看货品位置
 * */
export const getLocation = params => {
  return axios.request({
    url: '/sysInbound/selPosition',
    params,
    method: 'post'
  })
}

/**
 * 获取导出数据
 * */
export const getExcel = data => {
  let url = `${config.baseUrl.pro}/sysInbound/exportSysByDetails?colors=${data.colors}&endDate=${data.endDate}&goodsName=${data.goodsName}&remarks=${data.remarks}&sectionNum=${data.sectionNum}&sizes=${data.sizes}&startDate=${data.startDate}&tenantId=${data.tenantId ? data.tenantId : ''}&vendorId=${data.vendorId ? data.vendorId : ''}`
  return url
}

/**
 * 按挂单查询
 * */
export const cacheList = data => {
  return axios.request({
    url: '/sysInbound/queryHang',
    data,
    method: 'post'
  })
}

/**
 * 按订货查询
 * */
export const getOrderList = data => {
  return axios.request({
    url: '/sysInbound/selSysOrdering',
    data,
    method: 'post'
  })
}

/**
 * 按订货查询=> 确认订单
 * */
export const affirmOrder = data => {
  return axios.request({
    url: '/sysInbound/confirmSysOrdering',
    data,
    method: 'post'
  })
}

/**
 * 按订货查询=> 作废
 * */
export const cancellation = data => {
  return axios.request({
    url: '/sysInbound/obsSysOrdering',
    data,
    method: 'post'
  })
}

/**
 * 按订货查询 => 查询订单详情
 * */
export const getOrderDetails = data => {
  return axios.request({
    url: '/sysInbound/getUpdInfo',
    data,
    method: 'post'
  })
}

/**
 * 按订货查询 => 修改
 * */
export const orderAmend = data => {
  return axios.request({
    url: '/sysInbound/updSysOrdering',
    data,
    method: 'post'
  })
}

/**
 * 按租户id查询租户厂商列表
 * */
export const getVendorList = data => {
  return axios.request({
    url: '/queryVendorList',
    data,
    method: 'post'
  })
}

/**
 * 根据租户id跟厂商id查询款号列表
 * */
export const getSectionList = data => {
  return axios.request({
    url: '/querySection',
    data,
    method: 'post'
  })
}

/**
 * 根据租户id、厂商id、款号id查询商品列表
 * */
export const getGoodsList = data => {
  return axios.request({
    url: '/queryInboundGoods',
    data,
    method: 'post'
  })
}

/**
 * 保存
 * */
export const saveData = data => {
  return axios.request({
    url: '/addSysGoodsInfo',
    data,
    method: 'post'
  })
}

/**
 * 读取未保存信息
 * */
export const getSaveList = data => {
  return axios.request({
    url: '/readUnsavedInfo',
    data,
    method: 'post'
  })
}

/**
 * 未保存数据
 * */
export const getNotSaved = data => {
  return axios.request({
    url: '/queryUnsavedInfo',
    data,
    method: 'post'
  })
}
